﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;
using WisDom.SmartTMS.Dtos;
using WisDom.SmartTMS.Entities;
using WisDom.SmartTMS.Interface;

namespace WisDom.SmartTMS.Service
{
   public class UserService : ApplicationService, IUserService
    {
        //依赖注入于
        private readonly IRepository<Users> _userRepository;

        public UserService(IRepository<Users> userRepository)
        {
            _userRepository = userRepository;
        }
        //异步登录
        public async Task<UserDto> Get(string UserName, string password)
        {
            //async await做了个异步 可以使异步像同步执行 C#里面的语法糖
            var user = await _userRepository.GetAsync(m => m.UserName == UserName && m.PassWord == password);
            //转换成用户Dto  原数据 映射数据
            var dto = ObjectMapper.Map<Users, UserDto>(user);
            return dto;
        }
    }
}
